package com.interview.ribbon;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class RibbonConsumerServiceImpl implements RibbonConsumerServiceAPI {

    @Autowired
    private RestTemplate restTemplate;

    @Override
    public String sayHello(String id) {
        String uri = "/name/"+id;
        //只填写服务名，服务路径自动发现 ribbon有发现服务的功能
        String url="http://interview-provider-1"+uri;
        // invoker
        String result = restTemplate.getForObject(url, String.class);
        return result;
    }
}
